PostgreSQL: Support SQL standard ARRAY keyword in type declarations#2356
PostgreSQL: Support SQL standard ARRAY keyword in type declarations#2356LucaCappelletti94 wants to merge 8 commits into
ARRAY keyword in type declarations#2356Conversation
|
Hit this same limitation independently: production Flyway migrations using the SQL-standard keyword form on a user-defined type ( 1. Enable it for GenericDialect. The README asks for dialect-specific syntax to be accepted by both the relevant dialect and GenericDialect, and the bracket form's // src/dialect/generic.rs
+ fn supports_array_typedef_with_keyword(&self) -> bool {
+ true
+ }2. Widen the tests. The current tests cover built-in element types in CREATE TABLE and CAST. These cases exercise different paths (custom and schema-qualified type names, ALTER TABLE, parenthesized typmods, and the suffix-vs-constructor ambiguity) and are worth pinning: pg_and_generic().verified_stmt("CREATE TABLE t (c currency ARRAY)");
pg_and_generic().verified_stmt("CREATE TABLE t (c public.currency ARRAY)");
pg_and_generic().verified_stmt("ALTER TABLE t ADD COLUMN c currency ARRAY");
pg_and_generic().verified_stmt("CREATE TABLE t (c NUMERIC(10,2) ARRAY)");
pg_and_generic().verified_stmt("CREATE TABLE t (c INT ARRAY DEFAULT ARRAY[]::INT[])");( Can send both as a patch against your branch if that's easier. |
|
@iffyio could you check this out when you have time? |
Adds support for the SQL standard
ARRAYkeyword in array type declarations, such asINTEGER ARRAYandINTEGER ARRAY[4], which PostgreSQL accepts anywhere a type is expected (column definitions, casts, and the::operator). It is gated behind a newDialect::supports_array_typedef_with_keywordmethod, enabled for PostgreSQL, and the keyword form with its optional cardinality is represented by a newArrayElemTypeDef::Keywordvariant.This also unifies the existing MySQL multi-valued index syntax
CAST(... AS UNSIGNED ARRAY). Thearray: boolfield onExpr::Castis removed and the trailingARRAYkeyword is now captured throughArrayElemTypeDef::Keywordfor every dialect, so this is a breaking change to the AST. Parser behavior is unchanged for all dialects, only the representation is unified, and round-trip serialization is preserved.